home *** CD-ROM | disk | FTP | other *** search
/ The 640 MEG Shareware Studio 2 / The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO / basic / apbsu100.zip / FILE-MAN.BAS < prev    next >
BASIC Source File  |  1992-01-11  |  13KB  |  609 lines

  1. start:
  2.  
  3. ' Set up and print intro screen.
  4.  
  5. cls
  6. print "                     The ApBASIC File Manager, Version 1
  7. print
  8. print
  9. print "                              By Matt Roberts
  10. print "                              3 Cedar St., # 8
  11. print "                          Montpelier, Vt 05602-3006
  12. print "                                (802)223-2553
  13. print
  14. print
  15. print "If you find the files on this disk useful, a donation of $5.00 would be
  16. print "greatly appreciated.  Thanks.
  17. print
  18. print
  19. print "If you're having trouble using this program, and the documentation
  20. print "doesn't seem to help, you can call me between 9AM and 9PM EST, and I'll
  21. print "try to help.
  22. print
  23. print
  24. print
  25. gosub presskey
  26.  
  27. 'Opening screen is now set up and printed.
  28.  
  29.  
  30. '                          Now create a menu of options.
  31.  
  32.  
  33. menu:
  34. cls
  35. locate 1,35
  36. print "Your options:
  37. print
  38. print
  39. print "1- Work with CONFIG.SYS file.                            9- Get time/date."
  40. print
  41. print "2- Work with AUTOEXEC.BAT file.                          10- Quit."
  42. print
  43. print "3- Delete files."
  44. print
  45. print "4- Make directory.
  46. print
  47. print "5- Display file contents."
  48. print
  49. print "6- Copy a file."
  50. print
  51. print "7- Get file length."
  52. print
  53. print "8- Move file."
  54. print
  55. print
  56. input "Please press the number of your choice, and then press Enter. ",choice
  57. on choice gosub changecon,chngauto,killfile,makedir,displafl,copyfile,filength,movefile,timedate,quitprog
  58. goto menu
  59.  
  60. 'This is the end of the menu.
  61.  
  62.  
  63.  
  64. 'Here is the routine for working with the CONFIG.SYS file.
  65.  
  66. changecon:
  67. cls
  68. print "                      View or Change Your CONFIG.SYS File
  69. print
  70. print
  71. input "On which drive is your CONFIG.SYS file";drive$
  72. redrive:
  73. drive$=drive$+"\"
  74. if drive$="a:\" then file1$="a:\config.sys
  75. if drive$="A:\" then file1$="a:\config.sys
  76. if drive$="b:\" then file1$="b:\config.sys
  77. if drive$="B:\" then file1$="b:\config.sys
  78. if drive$="c:\" then file1$="c:\config.sys
  79. if drive$="C:\" then file1$="c:\config.sys
  80. if drive$="d:\" then file1$="d:\config.sys
  81. if drive$="D:\" then file1$="d:\config.sys
  82. if drive$="a:\" then file2$="a:\config.bas
  83. if drive$="A:\" then file2$="a:\config.bas
  84. if drive$="b:\" then file2$="b:\config.bas
  85. if drive$="B:\" then file2$="b:\config.bas
  86. if drive$="c:\" then file2$="c:\config.bas
  87. if drive$="C:\" then file2$="c:\config.bas
  88. if drive$="d:\" then file2$="d:\config.bas
  89. if drive$="D:\" then file2$="d:\config.bas
  90.  
  91. confmenu:
  92. cls
  93. print "You have the following options:"
  94. print
  95. print
  96. print "1- Just view the CONFIG.SYS file."
  97. print
  98. print "2- Add lines to the end of your file."
  99. print
  100. print "3- Create a new CONFIG.SYS file."
  101. print
  102. print "4- Return to the Main Options Menu."
  103. print
  104. print
  105. print
  106. input "Please press the number corresponding to your choice, and then press Enter. ",chngview$
  107. if chngview$="1" then cls:gosub seesys:goto confmenu
  108. if chngview$="2" then cls:gosub appendln:gosub seesys:goto confmenu
  109. if chngview$="3" then cls:goto newfilec
  110. if chngview$="4" then goto menu
  111. goto confmenu
  112.  
  113.  
  114.  
  115. 'This section creates a new CONFIG.SYS file.
  116.  
  117. newfilec:
  118. cls
  119. open file1$ for input as 1
  120. open file2$ for output as 2
  121. while not eof(1)
  122. line input # 1, a$
  123. print# 2, a$
  124. wend
  125. close # 1
  126. close # 2
  127. kill file1$
  128. print
  129. print
  130. print "Your CONFIG.SYS file has been changed to CONFIG.BAS in order to save it for
  131. print "future use.  To use it later, it will have to be renamed to something else
  132. print "(for example, CONFIG.X)."
  133. print
  134. print
  135. print
  136. gosub presskey
  137.  
  138. changeagn:
  139. cls
  140. open file1$ for output as 1
  141. print "How many files do you want?
  142. input "To quit, press Q and Enter. ",filenumb$
  143. if filenumb$="q" or filenumb$="Q" then goto restorec
  144. print# 1, "files=";filenumb$
  145. print
  146. print
  147. print
  148. input "How many buffers do you want";buffer$
  149. print# 1, "buffers=";buffer$
  150.  
  151. devcagain:
  152. print
  153. input "Which device would you like to include (N for none)";device$
  154. if device$="n" or device$="N" then goto nodevice
  155. print# 1, "devices=";device$
  156. print
  157. input "Would you like to include more devices";incldmore$
  158. if incldmore$="y" or incldmore$="Y" then goto devcagain
  159.  
  160. nodevice:
  161. print
  162. input "Do you want Break on or off (if not sure, type OFF)";breakyn$
  163. if breakyn$="on" or breakyn$="ON" then print# 1, "break=on
  164. close # 1
  165. gosub seesys
  166. print
  167. print
  168. print
  169. print "If this is not O.K. AND you want to go back and change the file, press C and
  170. print "then press Enter."
  171. print
  172. print "To restore your original CONFIG.SYS file, press R and Enter.
  173. print
  174. input "If you're happy with it as is, type OK and Enter. ",change$
  175.  
  176. okdecide:
  177. if change$="c" or change$="C" then goto changeagn
  178. if change$="r" or change$="R" then goto restorec
  179. if change$="ok" or change$="OK" then goto confmenu
  180. print
  181. input "You must choose between C, R, or OK. ",change$:goto okdecide
  182.  
  183.  
  184. restorec:
  185. cls
  186. reset
  187. kill file1$
  188. open file2$ for input as 1
  189. open file1$ for output as 2
  190. while not eof(1)
  191. line input # 1, a$
  192. print# 2, a$
  193. wend
  194. reset
  195. print "Your original CONFIG.SYS file has been restored."
  196. gosub presskey
  197. goto confmenu
  198.  
  199. 'This is the end of the routine for working with the CONFIG.SYS file.
  200.  
  201.  
  202.  
  203. ' Here is the routine for working with the AUTOEXEC.BAT file.
  204.  
  205. chngauto:
  206. cls
  207. print "                     View or Change Your AUTOEXEC.BAT File
  208. print
  209. print
  210. input "On which drive is your AUTOEXEC.BAT file";drive$
  211. redrivea:
  212. drive$=drive$+"\"
  213. if drive$="a:\" then file1$="a:\autoexec.bat"
  214. if drive$="A:\" then file1$="a:\autoexec.bat"
  215. if drive$="b:\" then file1$="b:\autoexec.bat"
  216. if drive$="B:\" then file1$="b:\autoexec.bat"
  217. if drive$="c:\" then file1$="c:\autoexec.bat"
  218. if drive$="C:\" then file1$="c:\autoexec.bat"
  219. if drive$="d:\" then file1$="d:\autoexec.bat"
  220. if drive$="D:\" then file1$="d:\autoexec.bat"
  221. if drive$="e:\" then file1$="e:\autoexec.bat"
  222. if drive$="E:\" then file1$="e:\autoexec.bat"
  223.  
  224. if drive$="a:\" then file2$="a:\autoexec.bas"
  225. if drive$="A:\" then file2$="a:\autoexec.bas"
  226. if drive$="b:\" then file2$="b:\autoexec.bas"
  227. if drive$="B:\" then file2$="B:\autoexec.bas"
  228. if drive$="c:\" then file2$="c:\autoexec.bas"
  229. if drive$="C:\" then file2$="c:\autoexec.bas"
  230. if drive$="d:\" then file2$="d:\autoexec.bas"
  231. if drive$="D:\" then file2$="d:\autoexec.bas"
  232. if drive$="e:\" then file2$="e:\autoexec.bas"
  233. if drive$="E:\" then file2$="e:\autoexec.bas"
  234.  
  235. automenu:
  236. cls
  237. print "You have the following options:"
  238. print
  239. print
  240. print "1- Just view the AUTOEXEC.BAT file."
  241. print
  242. print "2- Add lines to the end of your file."
  243. print
  244. print "3- Create a new AUTOEXEC.BAT file."
  245. print
  246. print "4- Return to the Main Options Menu.
  247. print
  248. print
  249. print
  250. input "Please press the number corresponding to your choice, and then press Enter. ",chngauto$
  251.  
  252. if chngauto$="1" then
  253. cls
  254. gosub autolook
  255. goto automenu
  256. elseif chngauto$="2" then
  257. cls
  258. gosub appndaut
  259. gosub autolook
  260. goto automenu
  261. elseif chngauto$="3" then
  262. cls
  263. goto newauto
  264. elseif chngauto$="4" then
  265. cls
  266. return
  267. else
  268. goto automenu
  269. end if
  270.  
  271.  
  272. ' This routine creates a new AUTOEXEC.BAT file.
  273.  
  274. newauto:
  275. cls
  276. open file1$ for input as 1
  277. open file2$ for output as 2
  278. while not eof(1)
  279. line input # 1, a$
  280. print # 2, a$
  281. wend
  282. close # 1
  283. close # 2
  284. kill file1$
  285. cls
  286. print "Your AUTOEXEC.BAT file has been changed to AUTOEXEC.BAS in order to
  287. print "save it for later use.  To use it later, you will have to
  288. print "rename it AUTOEXEC.BAT after renaming the current AUTOEXEC.BAT to
  289. print "something else (for example, AUTOEXEC.X)."
  290. print
  291. print
  292. gosub presskey
  293.  
  294. scndchng:
  295. cls
  296. open file1$ for output as 1
  297. print "Please type the first line you want, then press Enter (Q to quit).
  298. print
  299. input "> ",firstln$
  300.  
  301. if firstln$="q" then
  302. goto nochange
  303. elseif firstln$="Q" then
  304. goto nochange
  305. end if
  306.  
  307. print # 1, firstln$
  308.  
  309. contline:
  310. print
  311. print "Please type your next line, followed by Enter (Q to quit).
  312. print
  313. input "> ",nextline$
  314.  
  315. if nextline$="q" then
  316. goto stopchng
  317. elseif nextline$="Q" then
  318. goto stopchng
  319. end if
  320.  
  321. print # 1, nextline$
  322. goto contline
  323.  
  324. stopchng:
  325. close # 1
  326. cls
  327. gosub autolook
  328. print
  329. print
  330. print
  331. print "If this is not O.K. AND you want to change it, press C and then Enter."
  332. print
  333. print "To restore your original AUTOEXEC.BAT, press R and then Enter.
  334. print
  335. input "If you're happy with it as is, type OK and Enter. ",changeyn$
  336.  
  337. rechange:
  338. if changeyn$="c" then
  339. goto scndchng
  340. elseif changeyn$="C" then
  341. goto scndchng
  342. elseif changeyn$="r" then
  343. goto nochange
  344. elseif changeyn$="R" then
  345. goto nochange
  346. elseif changeyn$="ok" then
  347. goto automenu
  348. elseif changeyn$="OK" then
  349. goto automenu
  350. elseif changeyn$="oK" then
  351. goto automenu
  352. elseif changeyn$="Ok" then
  353. goto automenu
  354. end if
  355.  
  356. print
  357. input "You must choose C, R, or OK. ",changeyn$
  358. goto rechange
  359.  
  360. nochange:
  361. cls
  362. reset
  363. kill file1$
  364. open file2$ for input as 1
  365. open file1$ for output as 2
  366.  
  367. while not eof(1)
  368. line input # 1, a$
  369. print # 2, a$
  370. wend
  371.  
  372. reset
  373. print "Your original AUTOEXEC.BAT file has been restored.
  374. gosub presskey
  375. goto automenu
  376.  
  377. ' This is the end of the routine for working with the AUTOEXEC.BAT file.
  378.  
  379.  
  380. ' Here is the routine for deleting files.
  381.  
  382. killfile:
  383. cls
  384. print "                                 Delete Files
  385. print
  386. print
  387. print "Before going any further you should be aware that, once a file has"
  388. print "been deleted, it is very difficult to retrieve it.  From this program,"
  389. print "it is impossible; there is no undelete option available."
  390. print
  391.  
  392. deletagn:
  393. input "Press Enter to continue, or Q and Enter to quit. ",contyn$
  394. if contyn$="q" or contyn$="Q" then return
  395. cls
  396. input "File to delete (include drive and path)";file$
  397. print
  398. print
  399. print "All the data in "ucase$(file$)" will be destroyed."
  400. print
  401. print
  402. input "Press Enter to continue or Q and Enter to quit. ",contyn$
  403. if contyn$="q" or contyn$="Q" then return
  404. kill file$
  405. print
  406. print
  407. print ucase$(file$)" has been deleted."
  408. print
  409.  
  410. another:
  411. input "Delete another";delagain$
  412. if delagain$="y" or delagain$="Y" then goto deletagn
  413.  
  414. if delagain$="n" or delagain$="N" then
  415. print
  416. return
  417. end if
  418.  
  419. cls
  420. goto another
  421.  
  422. ' This is the end of the routine for deleting files.
  423.  
  424.  
  425.  
  426.  
  427.  
  428. makedir:
  429. cls
  430. print "                               Make a Directory"
  431. print
  432. print
  433.  
  434. mkdagain:
  435. input "Which drive (Q to quit)";drive$
  436. if drive$="q" or drive$="Q" then return
  437.  
  438. redrivem:
  439. print
  440. input "Directory name (include path)";directory$
  441. directory$=drive$+"\"+directory$
  442. mkdir directory$
  443. print
  444. print
  445. print
  446. print "You have created directory: "ucase$(directory$)
  447. print
  448. print
  449. input "Would you like to make another directory";makeagn$
  450.  
  451. if makeagn$="y" or makeagn$="Y" then
  452. print
  453. print
  454. goto mkdagain
  455. end if
  456.  
  457. return
  458.  
  459. 'This is the end of the routine for making directories.
  460.  
  461.  
  462. 'Here is the routine for displaying file contents.
  463.  
  464. displafl:
  465. cls
  466. displagn:
  467. print "                              View File Contents"
  468. print
  469. print
  470. print "Which file (include drive and path)?"
  471. input "Press Q and Enter to quit. ",whatfile$
  472. if whatfile$="q" or whatfile$="Q" then return
  473. cls
  474. print "To pause, press Ctrl-Num Lock."
  475. print
  476. print "Special characters used in ";ucase$(whatfile$)
  477. print "may not print in exactly the same manner as the original."
  478. print
  479. print "Also, formatting may not be quite correct."
  480.  
  481. refiledf:
  482. gosub presskey
  483. cls
  484. open whatfile$ for input as 1
  485. while not eof(1)
  486. line input # 1, a$
  487. print a$
  488. wend
  489. close 1
  490. print
  491. input "Do you want to view more files";viewmore$
  492. if viewmore$="y" or viewmore$="Y" then goto displagn
  493. return
  494.  
  495. 'This is the end of the routine for displaying files.
  496.  
  497.  
  498. copyfile:
  499. return
  500.  
  501. filength:
  502. return
  503.  
  504. movefile:
  505. return
  506.  
  507. timedate:
  508. return
  509.  
  510. quitprog:
  511. cls
  512. end
  513.  
  514. ' Here is the routine for looking at the CONFIG.SYS file.
  515.  
  516. seesys:
  517. reset
  518. cls
  519. print "Here is your file:"
  520. print
  521. open file1$ for input as 1
  522. while not eof(1)
  523. line input # 1, a$
  524. print a$
  525. wend
  526. close # 1
  527. gosub presskey
  528. return
  529.  
  530. 'This is the end of the routine for looking at the CONFIG.SYS file.
  531.  
  532.  
  533.  
  534. 'Here is the routine for adding lines to the end of CONFIG.SYS.
  535.  
  536. appendln:
  537. reset
  538. open file1$ for append as 1
  539.  
  540. appendagn:
  541. print
  542. input "Line to add (Q to quit)";appendln$
  543. if appendln$="q" or appendln$="Q" then close # 1:return
  544. print# 1, appendln$
  545. goto appendagn
  546.  
  547. 'This is the end of the routine for adding lines to CONFIG.SYS.
  548.  
  549.  
  550.  
  551. ' Here is the routine for looking at the AUTOEXEC.BAT file.
  552.  
  553. autolook:
  554. cls
  555. reset
  556. print "Here is your file:"
  557. print
  558. print
  559. open file1$ for input as 1
  560.  
  561. while not eof(1)
  562. line input # 1, a$
  563. print a$
  564. wend
  565.  
  566. close # 1
  567. gosub presskey
  568. return
  569.  
  570. ' This is the end of the routine for looking at the AUTOEXEC.BAT file.
  571.  
  572.  
  573. ' Here is the routine for adding lines to the end of AUTOEXEC.BAT.
  574.  
  575. appndaut:
  576. cls
  577. reset
  578. open file1$ for append as 1
  579.  
  580. appndagn:
  581. print
  582. input "Line to add (Q to quit)";appendln$
  583.  
  584. if appendln$="q" then
  585. close # 1
  586. return
  587. elseif appendln$="Q" then
  588. close # 1
  589. return
  590. end if
  591.  
  592. print # 1, appendln$
  593. goto appndagn
  594.  
  595. ' This is the end of the routine for adding to the end of AUTOEXEC.BAT.
  596.  
  597.  
  598.  
  599. 'Here is the routine for waiting for the user to press any key to continue.
  600.  
  601. presskey:
  602. print
  603. print
  604. print "Press any key to continue. "
  605. wait:
  606. wait$=inkey$
  607. if wait$="" then goto wait
  608. return
  609.